# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=cue-cli
pkgver=0.7.0
pkgrel=0
pkgdesc="CLI for CUE configuration and validation language"
url="https://cuelang.org/"
# 32-bit: value out of int range
# s390x: TextExe fails (slice bounds out of range)
arch="all !x86 !armhf !armv7 !s390x"
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
options="net"
source="$pkgname-$pkgver.tar.gz::https://github.com/cue-lang/cue/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/cue-$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v -o bin/cue \
		-ldflags "-X cuelang.org/go/cmd/cue/cmd.version=v$pkgver" \
		./cmd/cue/

	for shell in bash fish zsh; do
		./bin/cue completion $shell > cue.$shell
	done
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/cue -t "$pkgdir"/usr/bin/

	install -Dm644 cue.bash \
		"$pkgdir"/usr/share/bash-completion/completions/cue
	install -Dm644 cue.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/cue.fish
	install -Dm644 cue.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_cue
}

sha512sums="
471ebc4ac81dfc0df42d8e8bd5e858b8a2f958c909ccd0b391ed4af669e7eba3908bcde63ca21973f072e35f66d307180fb3fc43627eb4de6385011bcf48aed1  cue-cli-0.7.0.tar.gz
"
